//
//  OMPaymentInfoTableCell.m
//  OMENGO_NEW
//
//  Created by 梁尚嘉 on 2017/5/9.
//  Copyright © 2017年 Kamfat. All rights reserved.
//

#import "OMPaymentInfoTableCell.h"
#import "OMPaymentResponse.h"
@interface OMPaymentInfoTableCell()
@property (nonatomic, strong) UILabel *totalPriceLabel;
@property (nonatomic, strong) UILabel *totalDetailPriceLabel;
@property (nonatomic, strong) UILabel *discountLabel;
@property (nonatomic, strong) UILabel *discountDetailLabel;
@property (nonatomic, strong) UILabel *amountLabel;
@property (nonatomic, strong) UILabel *amountDetailLabel;
@end

@implementation OMPaymentInfoTableCell

- (void)configureCellWithObj:(OMPaymentResponse *)response
{
    self.totalDetailPriceLabel.text = [[NSString stringWithFormat:@"￥%.2f",response.orderTotal.floatValue]  stringByReplacingOccurrencesOfString:@".00" withString:@""];
    self.discountDetailLabel.text = [[NSString stringWithFormat:@"-￥%.2f",response.couponDiscount]  stringByReplacingOccurrencesOfString:@".00" withString:@""];
    self.amountDetailLabel.text = [[NSString stringWithFormat:@"￥%.2f",response.amount.floatValue]  stringByReplacingOccurrencesOfString:@".00" withString:@""];
}


- (void)configure
{
    [super configure];

    UIView *line = [[UIView alloc]init];
    line.backgroundColor = HEXCOLOR(@"#F5F5F6");
    [self.containView addSubview:line];
    [line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.equalTo(@0);
        make.width.equalTo(@1.f);
        make.centerX.equalTo(self.containView.mas_centerX);
    }];

    _totalPriceLabel = [UILabel new];
    _totalPriceLabel.font = SM_CFont(29);
    _totalPriceLabel.textColor = HEXCOLOR(@"9f9f9f");
    _totalPriceLabel.text = @"总价";
    [self.containView addSubview:_totalPriceLabel];
    [_totalPriceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@(SM_SIZE(30)));
        make.top.equalTo(@(SM_SIZE(30)));
    }];

    _discountLabel = [UILabel new];
    _discountLabel.font = SM_CFont(29);
    _discountLabel.textColor = HEXCOLOR(@"9f9f9f");
    _discountLabel.text = @"优惠";
    [self.containView addSubview:_discountLabel];
    [_discountLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.totalPriceLabel.mas_left);
        make.bottom.equalTo(@(SM_SIZE(-30)));
    }];

    _totalDetailPriceLabel = [UILabel new];
    _totalDetailPriceLabel.font = SM_CFont(29)  ;
    _totalDetailPriceLabel.textColor = SM_blackColor;
    _totalDetailPriceLabel.text = @"￥9.00";
    [self.contentView addSubview:_totalDetailPriceLabel];
    [_totalDetailPriceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(line.mas_left).offset(SM_SIZE(-30));
        make.top.equalTo(self.totalPriceLabel.mas_top);
    }];


    _discountDetailLabel = [UILabel new];
    _discountDetailLabel.font = SM_CFont(29)  ;
    _discountDetailLabel.textColor = SM_blackColor;
    _discountDetailLabel.text = @"-￥0.00";
    [self.contentView addSubview:_discountDetailLabel];
    [_discountDetailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(line.mas_left).offset(SM_SIZE(-30));
        make.top.equalTo(self.discountLabel.mas_top);
    }];

    _amountLabel = [UILabel new];
    _amountLabel.font = SM_CFont(29);
    _amountLabel.textColor = HEXCOLOR(@"9f9f9f");
    _amountLabel.text = @"还需支付";
    _amountLabel.textAlignment = NSTextAlignmentCenter;
    [self.containView addSubview:_amountLabel];
    [_amountLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(line.mas_right).offset(SM_SIZE(30));
        make.right.equalTo(@(SM_SIZE(-30)));
        make.top.equalTo(@(SM_SIZE(25)));
    }];

    _amountDetailLabel = [UILabel new];
    _amountDetailLabel.font = SM_CBFont(50);
    _amountDetailLabel.textColor = SM_redColor;
    _amountDetailLabel.text = @"￥9.00";
    _amountDetailLabel.textAlignment = NSTextAlignmentCenter;
    [self.containView addSubview:_amountDetailLabel];
    [_amountDetailLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.amountLabel.mas_left);
        make.right.equalTo(self.amountLabel.mas_right);
        make.bottom.equalTo(@(SM_SIZE(-30)));
    }];
}


+ (CGFloat)cellHeight
{
    return SM_SIZE(200);
}
@end
